<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
</head>
<body>
<div class="layui-form" style="padding: 40px">
    <div class="layui-form-item">
        <label class="layui-form-label">名称:</label>
        <div class="layui-input-block">
            <input type="text" name="permissionName" lay-verify="required" autocomplete="off"
                   class="layui-input">
            <input id="parentId" name="parentId" th:value="${permission.permissionId}" hidden/>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">权限标识符:</label>
            <div class="layui-input-inline">
                <input id="mark" type="text" name="Mark"
                       th:value="${permission.permissionMark}" disabled="disabled"
                       class=" layui-input layui-disabled"/>
            </div>
            <div class="layui-input-inline" style="width: auto">
                <input id="markAdd" value="" type="text" name="Markadd" lay-verify="required" class="layui-input"
                />
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型:</label>
        <div class="layui-input-block">
            <select id="permissionType" name="permissionType">
                <option>menu</option>
                <option>button</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">URL:</label>
        <div class="layui-input-block">
            <input type="text" name="url" lay-verify="required" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">优先级:</label>
        <div class="layui-input-block">
            <input type="number" name="priority" lay-verify="required" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">图标:</label>
            <div class="layui-input-inline">
                <input name="icon" id="icon" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width: auto">
                <span style="line-height: 35px;color: #777777">注意:仅对一级菜单生效</span>
            </div>
        </div>
    </div>
    <div class="layui-form-item" style="position: fixed;bottom: 0px;right: 10px;">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="Submit">保存内容</button>
            <button type="" class="layui-btn layui-btn-primary close">取消</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript">

    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            form = layui.form;
        $('.close').on('click', function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        })
        form.on('submit(Submit)', function (data) {
            var mark = $("#mark").val() + ":"
            var addMark = $("#markAdd").val()
            data.field.permissionMark = mark + addMark;
            $.ajax({
                url: '/menu/addMenu.do',
                type: 'post',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (result.status) {
                        parent.layer.msg("添加成功!", {time: 1000});
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.layui.table.reload('tableId', {});
                        parent.window.location.reload()
                    } else {
                        layer.msg(result.msg);
                    }
                }

            });
        });
    });

</script>
</body>
</html>
